package com.jiawa.wiki.controller;

import com.jiawa.wiki.domain.Test;
import com.jiawa.wiki.service.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * 测试
 *  为什么能扫描到下面的注解呢？是启动类中注解@SpringBootApplication有@ComponentScan
 */
@RestController
public class TestController {

    @Value("${test.hello: xxx}")
    private String name;

    @Resource
    private TestService testService;

    //@RequestMapping(value = "/hello", method = RequestMethod.GET)
    @GetMapping("/hello")
    public String hello() {
        return "hello world " + name;
    }

    @PostMapping("/hello/post")
    public String helloPost(String name) {
        return "hello post " + name;
    }

    /**
     * 测试 mybatis
     * @return
     */
    @GetMapping("/test/list")
    public List<Test> list() {
        return testService.list();
    }
}
